﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="VerificationCode.cs" company="HelloWorld">
//   BY田新宇
// </copyright>
// <summary>
//   生成验证码
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WindowsFormsApp2.Service
{
    using System;

    // 验证码

    /// <summary>
    /// The verification code.
    /// </summary>
    internal class VerificationCode
    {
        // 随机生成验证码

        /// <summary>
        /// The code.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string Code()
        {
            var code = string.Empty;           // 验证码字符串
            var ran = new Random();
            for (var i = 0; i < 4; i++)
            {
                // 随机生成四位验证码
                var n = ran.Next(9);
                code += n;
            }

            return code;
        }
    }
}
